<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>注册界面</title>
	<link rel="stylesheet" href="assets/css/reset.css" />
	<link rel="stylesheet" href="assets/css/common.css" />
	<link rel="stylesheet" href="assets/css/font-awesome.min.css" />
	<link rel="stylesheet" type="text/css" href="http://cdn.bootcss.com/font-awesome/4.6.0/css/font-awesome.min.css">
	<link rel="stylesheet" href="assets/css/amazeui.min.css">
	<link rel="stylesheet" href="assets/css/amazeui.cropper.css">
	<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
	<script src="assets/js/layui.js" charset="utf-8" type="text/javascript"></script>
	<link rel="stylesheet" href="assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="assets/js/layer.css"  media="all">


</head>
	<body>
		<div class="wrap login_wrap" >
			<div class="content">
				<div class="logo"></div>
				<div class="login_box">

					<div class="login_form">
						<div class="login_title">
							登录
						</div>
						<form action="#" method="post">

							<div class="layui-input-block">
								<input id="username" type="text" name="title" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
							</div>
							<div class="layui-input-block">
								<input id="password" type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
							</div>

							<div class="form_btn">
								<button type="button" onclick="login()">登录</button>
							</div>
							<div class="form_reg_btn">
								<span>还没有帐号？</span><a href="register.html">马上注册</a>
							</div>
						</form>
						<div class="other_login">
							<div class="left other_left">
								<span>其它登录方式</span>
							</div>
							<div class="right other_right">
								<a href="#"><i class="fa fa-qq fa-2x"></i></a>
								<a href="#"><i class="fa fa-weixin fa-2x"></i></a>
								<a href="#"><i class="fa fa-weibo fa-2x"></i></a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="assets/js/common.js" ></script>
		<script src="assets/js/amazeui.min.js" charset="utf-8"></script>
		<div style="text-align:center;">
			<script>
				var layer;
				layui.use(['layer', 'form'], function(){
					layer = layui.layer
							,form = layui.form;
				});
				function login() {
					var username = $("#username").val();
					var password = $("#password").val();

					if(username.length === 0){
						layer.msg("用户名不能空")
						return;
					}
					if(password.length === 0){
						layer.msg("密码不能空")
						return;
					}

					var user = {"username":username,"password":password}

					$.ajax({
						type: 'POST',
						url: 'http://localhost:8764/pcApi/login',
						dataType: 'json',
						contentType: "application/json",
						data:JSON.stringify(user),
						success: function (data) {
							if(data.errcode === "200"){
								localStorage.setItem("userId",data.data.id)
								layer.msg("登陆成功")
								setTimeout("window.location.href = 'lw-index.html'",2000)
							}
							else{
								layer.msg(data.errmsg)
							}
						},
						error: function (XMLHttpRequest, textStatus, errorThown) {
							layer.msg("操作失败！");
						}
					});

				}
			</script>

</div>
	</body>
</html>
